package cc.flybb.words;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import java.util.List;

@Dao
public interface WordDao {

        @Insert
        void insertWords(Word... words);

        @Update
        void updateWords(Word... words);

        @Delete
        void deleteWords(Word... words);

        @Query("DELETE FROM WORD")
        void deleteAllWords();

        @Query("SELECT * FROM WORD ORDER BY id DESC")
        LiveData<List<Word>> getAllWordsLive();

        //@Query("SELECT * FROM WORD ORDER BY id DESC")
        //DataSource.Factory<Integer, Word> getAllWords();

        @Query("SELECT * FROM WORD WHERE english_word LIKE :pattern ORDER BY id DESC")
        LiveData<List<Word>> findWordsWithPattern(String pattern);
}
